package greedy;

import java.util.Arrays;

public class leetcode455分发饼干 {
    public static int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int gIndex = 0;
        int sIndex = 0;
        int gLength = g.length;
        int sLength = s.length;
        int count = 0;
        while (gIndex < gLength && sIndex < sLength) {
            if (s[sIndex] >= g[gIndex]) {
                count++;
                gIndex++;
                sIndex++;
            } else {
                sIndex++;
            }
        }
        return count;
    }
}
